package com.leruan.aasimp.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.leruan.aasimp.dao.ForumststDao;
import com.leruan.aasimp.dao.MainPostDao;
import com.leruan.aasimp.entity.Forumstst;
import com.leruan.aasimp.entity.Mainpost;
import com.leruan.aasimp.entitydto.MainPostDto;
import com.leruan.aasimp.service.MainPostService;
import com.leruan.aasimp.util.DateUtils;

public class MainPostServiceImpl implements MainPostService {
    private MainPostDao mainPostDao;
    private ForumststDao forumststDao;

    public ForumststDao getForumststDao() {
        return forumststDao;
    }

    public void setForumststDao(ForumststDao forumststDao) {
        this.forumststDao = forumststDao;
    }

    public List<Mainpost> getMainPostsByBoardId(String boardId) {
        return mainPostDao.findMainPostsByBoardId(boardId);
    }

    public MainPostDao getMainPostDao() {
        return mainPostDao;
    }

    public void setMainPostDao(MainPostDao mainPostDao) {
        this.mainPostDao = mainPostDao;
    }

    public Mainpost getMainPostsByPostId(String postId) {
        return mainPostDao.findMainPostsByPostId(postId);
    }

    public List<Mainpost> getMainPostsNewest() {
        return mainPostDao.findMainPostsNewest();
    }

    public List<Mainpost> getMainPostsPopular() {
        Date dateEnd = DateUtils.addDay(new Date(), 1);
        Date dateStart = DateUtils.addDay(dateEnd, -30);
        return mainPostDao.findMainPostsPopular(dateStart, dateEnd);
    }

    public List<Mainpost> getMainPostsNewEssence() {
        return mainPostDao.findMainPostsNewEssence();
    }

    public void modifyMainPost(Mainpost mainpost) {
        mainPostDao.updateMainPost(mainpost);
    }

    public void addMainPost(Mainpost mainpost) {
        mainPostDao.insertMainPost(mainpost);
    }

    public void removeMainPost(Mainpost mainpost) {
        mainPostDao.deleteMainPost(mainpost);
    }

    public void modifyForumstst(Forumstst forumstst) {
        forumststDao.updateForumstst(forumstst);
    }

    public Forumstst getForumststByUserId(String userId) {
        return forumststDao.findForumststByUserId(userId);
    }

    public void addForumstst(Forumstst forumstst) {
        forumststDao.insertForumstst(forumstst);
    }

    public void removeForumstst(Forumstst forumstst) {
        forumststDao.deleteForumstst(forumstst);
    }

    public List<Forumstst> getForumststs() {
        return forumststDao.findForumststs();
    }

    public List<MainPostDto> getMainPostsByBoardId(String boardId, Map<String, String> map, int pageNo) {
        return mainPostDao.findMainPostsByBoardId(boardId, map, pageNo);
    }

    public Long getMainPostTotal(String boardId, Map<String, String> map) {
        return mainPostDao.findMainPostTotal(boardId, map);
    }

    public List<Mainpost> getMainPostsByUserId(String userId) {
        return mainPostDao.findMainPostsByUserId(userId);
    }

    public Long getMainPostNumById(String userId) {
        return mainPostDao.findMainPostNumById(userId);
    }

    public List<MainPostDto> getMainPostsByUserId(String userId, int pageNo) {
        return mainPostDao.findMainPostsByUserId(userId, pageNo);
    }
}
